<template>
  <div>
    <footer class="footer">
      <span class="todo-count"
        >剩余<strong>{{ num }}</strong></span
      >
      <ul @click="$emit('getType',type)" class="filters">
        <li>
          <a
            @click="type = 'all'"
            :class="{ selected: type === 'all' }"
            href="#/"
            >全部</a
          >
        </li>
        <li>
          <a
            @click="type = 'active'"
            :class="{ selected: type === 'active' }"
            href="#/active"
            >进行中</a
          >
        </li>
        <li>
          <a
            @click="type = 'completed'"
            :class="{ selected: type === 'completed' }"
            href="#/completed"
            >已完成</a
          >
        </li>
      </ul>
      <button v-show="showClear" @click="clear" class="clear-completed">
        清除已完成
      </button>
    </footer>
  </div>
</template>

<script>
export default {
  name: "VueTestTodoFooter",
  props: {
    list: {
      required: true,
      type: Array,
    },
  },
  data() {
    return {
      type: "all",
    };
  },
  computed: {
    num() {
      return this.list.length;
    },
    showClear() {
      return this.list.some((item) => item.isDone);
    },
  },
  methods: {
    clear() {
      this.$emit("clearName");
    },

  },
};
</script>

<style  scoped>
</style>